{% extends 'base.html' %}
{% load staticfiles %}



{% block content %}

    <h5>登录</h5>
    <form id="loginForm" action="#" method="post">
        用户:<br>
        <input type="text" id="username" name="username">
        <br>
        密码:<br>
        <input type="password" id="password" name="password">
        <input id="btn" type="button" value="立即购买">
    </form>

    <div class="copyright clearfix w1000_320">
        热点随时看
        <br/>
        Copyright &copy; 2019 . all rights reserved
    </div>



    {#{% include 'app_User/xxxx.html' %}#}
    {#    <a class="btn btn-default" href="{% url 'clearzhizhutxt' %}" role="button">清除蜘蛛访问记录</a>#}
    {#    <a class="btn btn-default" href="{% url 'cleartxt' %}" role="button">清除用户访问记录</a>#}

{% endblock %}
{% block script %}

    <script type="text/javascript">
        {#序列化https://www.cnblogs.com/ryxiong-blog/articles/10952356.html#}


        $("#btn").click(function () {
            $.ajax({
                type: "POST",
                dataType: "json",//预期服务器返回的数据类型
                url: "{% url 'stdlogin' %}",
                data: $("#loginForm").serialize(),
                cache: false,
                success: function (data) {
                    window.localStorage.setItem("token", data['data'][0]);
                    {#alert(data['data'])#}
                    var mytoken = window.localStorage.getItem("token");
                    var pageid = data['data'][1];
                    window.location.href = "{% url 'stdindex' %}?token=" + mytoken + "&pageid=" + pageid;
                    alert(mytoken)
                }
            });

            {#alert($("form").serialize())#}
        })

    </script>
{% endblock %}>